package org.jaaksi.kottlindemo.home

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import org.jaaksi.kottlindemo.databinding.FragmentCalcuatorBinding
import org.jaaksi.kottlindemo.databinding.FragmentHistoryBinding

class HistoryFragment : Fragment() {
    private lateinit var binding: FragmentHistoryBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentHistoryBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        // fixme 多个注册相同的requestKey时只有最后一个才能收到，还是用ViewModel吧
        parentFragmentManager.setFragmentResultListener("toast2", this) { requestKey, result ->
            println(">> HistoryFragment result = $result")
        }

    }
}